<template>
  <div>
    <el-dialog :title="'入库明细'" :visible.sync="addEditIsDialog_c" @close="resetForm('formName')" width="60%">
      <el-form :model="ruleForm" :rules="rules" ref="formName" label-width="120px" class="demo-ruleForm" :class="{ 'form-rules-show': seeType }">
        <el-row>
          <el-col :span="8">
            <el-form-item label="操作人：">
              {{ ruleForm.info.operator }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="洁衣入库时间：">
              {{ ruleForm.info.create_time }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="洁衣入库数量：">
              {{ ruleForm.info.counts }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-table :data="ruleForm.item" :border="true" :header-cell-style="tabHeadStyle" :cell-style="tabcellStyle" :row-style="rowStyle" max-height="650">
              <el-table-column label="织物属性" align="center">
                <el-table-column prop="type" label="织物类型" align="center"> </el-table-column>
                <el-table-column prop="classify" label="织物名称" align="center"> </el-table-column>
                <el-table-column prop="size" label="尺码" align="center"> </el-table-column>
              </el-table-column>
              <el-table-column prop="counts" label="入库数量" align="center"> </el-table-column>
            </el-table>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="resetForm('formName')">关 闭</el-button>
        <!-- <el-button type="primary" @click="submitForm('formName')">确 定</el-button> -->
      </div>
    </el-dialog>
  </div>
</template>
<script type="text/ecmascript-6">
import { clothActionInboundInfo } from "@/api/clothesDetail";

export default {
  props: {
    addEditId: {
      type: String,
      default: "",
    },
    create_time: {
      type: String,
      default: "",
    },
    addEditStatus: {
      type: String,
      default: "add",
    },
    addEditIsDialog: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      // 表头样式
      tabHeadStyle: {
        "background-color": "#f5f7fa",
        color: "#303133",
        "font-weight": "bold",
        "text-align": "center",
      },
      // 行样式
      tabcellStyle: {
        color: "#666",
      },
      rowStyle: {
        height: "16px",
      },
      ruleForm: {
        // 表单字段
        name: "",
        info:{},
        item: [],
        log: [],
      },
      rules: {
        // 表单规则
        name: [{ required: true, message: "请输入院区名称", trigger: "blur" }],
      },
      addEditIsDialog_c: false, // 弹窗是否显示
      seeType: false, // 是否禁用
      typeArray: [],
      activeId: '',
    };
  },
  watch: {
    addEditIsDialog(val) {
      this.addEditIsDialog_c = val;
      if (this.addEditIsDialog_c) {
        // 添加
        if (this.addEditStatus == "add") {
          this.ruleForm.id = "";
          this.seeType = false;
        }

        // 编辑
        if (this.addEditStatus == "edit") {
          this.ruleForm.id = this.addEditId;
          this.seeType = false;
          this.getDetail();
        }

        // 查看
        if (this.addEditStatus == "see") {
          this.ruleForm.id = this.addEditId;
          this.seeType = true;
          this.getDetail();
        }

      }
    }
  },
  methods: {
    // 详情
    getDetail() {
      clothActionInboundInfo({ handle_id: this.addEditId,create_time: this.create_time }).then((res) => {
        if (res.code == 200) {
          this.ruleForm = res.data;
        }
      });
    },
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
        if (columnIndex === 0) {
          if (rowIndex % 2 === 0) {
            return {
              rowspan: 2,
              colspan: 1
            };
          } else {
            return {
              rowspan: 0,
              colspan: 0
            };
          }
        }
      },
    // 取消
    resetForm(formName) {
      this.$refs[formName].resetFields();
      this.selectedValues = [];
      this.activeIndex = 0;
      this.$parent.closeAddEdit();
    },
  },
};
</script>

<style lang="less" scoped>
.demo-ruleForm {
  width: 95%;
  margin: 0 auto;
  padding-top: 10px;
}
.main {
  width: 100%;
  height: 100%;
  display: flex;
}
.card-item {
  width: 100%;
  height: 40px;
  line-height: 40px;
  cursor: pointer;
  border-bottom: solid 1px #f2f2f2;
  display: flex;
  justify-content: space-between;
  padding: 0px 10px;
}
// .card-item:hover{
//   background-color: #e8e8e8;
// }
.active {
  background-color: #d5e5e4;
}
.twoClass {
  display: flex;
  align-items: center;
  border: 1px solid #ebeef5;
}
.oneBox {
  // margin-left: 30px;
  // height: 15.62rem;
  // overflow: auto;
}
.twoBox {
  margin-left: 50px;
  display: flex;
  flex-direction: column;
  padding: 10px 10px;
}
.threeClass {
  display: flex;
  align-items: center;
  border: 1px solid #ebeef5;
}
.fourClass {
  display: flex;
  align-items: center;
  margin-top: 5px;
  // border: 1px solid #ebeef5;
}
.twocheckbox {
  width: 100px;
  display: flex;
  flex-direction: column;
  margin-left: 20px;
}
.threeBox {
  margin-left: 60px;
  margin-right: 30px;
  margin-bottom: 5px;
}
.trecheckbox {
  margin-left: 20px;
  margin-right: 20px;
  // display: flex;
  // flex-direction: column;
}
.box-card1 {
  width: 300px;
  height: 400px;
  margin-left: 90px;
}
</style>
